<?php
/**
 * Introduction: 新闻表  news
 */

namespace Common\Model;


use Think\Model;

class NewsModel extends Model
{
    //定义数据库连接信息
    protected $connection;

    //定义表名
    protected $tableName = 'news';

    /**
     * 初始化
     */
    public function _initialize()
    {

        $this->connection = C('Databaese');

    }

    /**
     *
     */
    public function getlist($catid,$num,$limit){
        $fields = ['nid', 'title', 'ftitle', 'titlepic', 'smalltext', 'uptime'];
        $list = $this->where("classid=$catid")->limit("$num,$limit")->field($fields)->select();
        foreach($list as $k=>$v){
            $list[$k]['uptime_format'] = date('Y年m月d日', $v['uptime']);
        }
        return $list;
    }


}